_Pragma("once")

#include "SystemStatisticInfo.h"
#include "TaskScheduler.h"
#include "SingletonTemplate.h"
#include "IExtendDeviceManager.h"
#include "StatisticInfoPersistor.h"
#include "MachineDependents.h"
#include "NetworkListener.h"
#include "SingletonTemplate.h"
#include "common.h"

class StatisticGatherer final : public NetworkListener{
public:
    friend SingletonTemplate<StatisticGatherer>;

    /** Default destructor */
    ~StatisticGatherer(void);

    void gatherStatisticInfo(void);

    void saveStatisticInfos(void);

    bool startupGather(void);

    bool stopGather(void);

    void resetInfoPersistor(void);

    void offline(INetwork* const network) override final;

    void online(INetwork* const network) override final;

    static StatisticGatherer& create(void);


    StatisticInfoPersistor minfoPersistor;

protected:
    StatisticGatherer();

    std::vector<SystemStatisticInfo> mstatisticInfos;

    IExtendDeviceManager& mextendDeviceManager;
    TaskScheduler& mtaskScheduler;

    TaskRecordPtr::weak_type mwptrGatherTask;
    TaskRecordPtr::weak_type mwptrSaveTask;
};


using StatisticGathererSingleton = SingletonTemplate<StatisticGatherer>;



